<?php

class DotForeignKeyRenderer {
	
	function Render( &$oConfiguration, &$oForeignKey ) {
		
		if ( ! $oConfiguration->GetProperty( 'ShowForeignKeysToFilteredTables' ) && $oForeignKey->ReferencesAFilteredTable() ) {
			return '';
		}
		
		$sKeyText = $oForeignKey->GetToTableName() . '--' . $oForeignKey->GetFromTableName();
		
		$aKeyProperties = array();
		
		if ( $oForeignKey->IsMandatory() ) {
			 $aKeyProperties[] = 'arrowtail=dot';
		} else {
			 $aKeyProperties[] = 'arrowtail=odot';
		}
		
		if ( $oConfiguration->GetProperty( 'ShowForeignKeyNames' ) ) {
			 $aKeyProperties[] = 'label="'.$oForeignKey->GetName().'"';
		}
		
		if ( $oForeignKey->IsFromAFilteredTable() ) {
			$sKeyText = DotTableRenderer::Render( $oConfiguration, $oForeignKey->GetFromTableName() ) . $sKeyText;	
		}
		
		if ( $oForeignKey->IsToAFilteredTable() ) {
			$sKeyText = DotTableRenderer::Render( $oConfiguration, $oForeignKey->GetToTableName() ) . $sKeyText;	
		}
		

		return $sKeyText . '[' . implode( ' ', $aKeyProperties ). ']' . "\n";			
	}
	
}

?>
